package com.beg.cant.controller;


import com.beg.cant.comment.result.Result;
import com.beg.cant.dto.ShopSettingsRequest;
import com.beg.cant.entity.ShopSettings;
import com.beg.cant.service.ShopSettingsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/api/shop/settings")
public class ShopSettingsController {
    
    @Autowired
    private ShopSettingsService shopSettingsService;

    @PostMapping
    public Result<Long> createOrUpdateSettings(@RequestBody ShopSettingsRequest request) {
        long id = shopSettingsService.saveOrUpdateSettings(request);
        return Result.success(id);
    }

    @GetMapping("/{id}")
    public Result<ShopSettings> getSettings(@PathVariable Long id) {
        ShopSettings settings = shopSettingsService.getSettings(id);
        return Result.success(settings);
    }

    @DeleteMapping("/{id}")
    public Result<Boolean> deleteSettings(@PathVariable Long id) {
        shopSettingsService.deleteSettings(id);
        return Result.success(true);
    }
}
